<?php
/**
 * 
 * IndexAction.class.php (前台首页)
 *
 * @package      	jgsat
 * @author          liuxun QQ:147613338 <admin@jgsat.cn>
 * @copyright     	Copyright (c) 2008-2011  (http://www.jgsat.com)
 * @license         http://www.jgsat.com/license.txt
 * @version        	jgsat企业网站管理系统 v2.1 2011-03-01 jgsat.cn $
 */
if(!defined("JGsat")) exit("Access Denied");
class TopicAction extends BaseAction
{
    function _initialize()
    {	
	parent::_initialize();
    }
    public function add()
    {
        if(!$this->_userid){
			$this->assign('jumpUrl',U('User/Login/index'));
			$this->error(L('nologin'));
			exit;
		}
        $this->assign('bcid',49);//顶级栏目 
        $this->display();
    }
    public function insert()
    {
        if(!$this->_userid){
            $this->assign('jumpUrl',U('User/Login/index'));
            $this->error(L('nologin'));
            exit;
        }
        $user = M('User')->find($this->_userid);
        $this->dao=M('Topic');
        $_POST['userid']=$this->_userid;
        $_POST['username']=$this->_username;
        $_POST['author']=$user["nickname"];
        $_POST['status']=1;
        $_POST['lang']=1;
        $_POST['createtime']=time();
        if(!$this->dao->create($_POST)) {
            $this->error($this->dao->getError());
        }
        $result	=	$this->dao->add();
        if(false !== $result) {
            $data['id']= $result;
            $data['url']= U('Home/Topic/show?id='.$result);
            $this->dao->save($data);
            $this->assign('jumpUrl',U('Home/Topic/show?id='.$result));
            $this->success(L('do_success'));
        }else{
            $this->error(L('do_error'));
        }
        exit;
    }
}
?>